$(function(){
	var currentMenu;
	$("#topMenu li.top > a").each(function(){
		if($(this).hasClass("now")){
			currentMenu = $(this);
		}
	});
	$("#topMenu li.top").each(function(){
		var target = $(this).children("ul.sub");
		var totalWidth = 0;
		target.children("li").each(function(){
			totalWidth+=$(this).width();
		});
		target.width(totalWidth);
		var topLeft = (totalWidth-$(this).width())/2;
		target.css("right",-topLeft+"px");
	});
	$("#topMenu li.top").hover(function(){
		var target = $(this).children("ul.sub");
		target.css("display","block");
	},
	function(){
		$(this).children("ul.sub").css("display","none");
	});
	$("#topMenu ul.sub").hover(function(){
		$(this).parent().children("a").addClass("now");
	},
	function(){
		$(this).parent().children("a").removeClass("now");
		currentMenu.addClass("now");
	});
});